<template>
	<view class="container">
		<view class="unit" v-on:click="modify">
			<view class="title">修改密码</view>
			<image class="more" mode="widthFix" src="../../static/images/more.png"></image>
		</view>
		<view class="unit" v-on:click="outlog">
			<view class="title">退出登录</view>
			<image class="more" mode="widthFix" src="../../static/images/more.png"></image>
		</view>
		<view class="unit" v-on:click="update_version">
			<view class="title">检查新版本</view>
			<view class="more_">当前版本号：V{{version}}</view>
		</view>
		<view class="company">当前版本号：V{{version}}</view>
	</view>
</template>
<style>
	page{background: #F4F4F4;}
	.company{width:100%;text-align: center;line-height:50upx;font-size:24upx;position: fixed;bottom:10upx;color: #888;}
	.container{background: #F4F4F4;display: flex;flex-direction: column;justify-content: space-between;align-items: center;}
	.unit{width:94%;padding:10upx 3%;border-bottom: 1px solid #F5F5F5;display: flex;justify-content: space-between;align-items: center;height: 80upx;background: #FFFFFF;}
	.title{width:50%;font-size: 28upx;color: #282828;}
	.more{width:30upx;}
	.more_{font-size:28upx;color: #282828;}
	.ad_unit{margin-top:100upx;}
	.ad_unit,.adclass{width: 100%;}
</style>
<script>
	export default {
		data() {
			return {
				member_id:0,
				pic_h:"",
				radius:'',
				menu_h:'',
				adpid:0,
				adData:{},
				width:0,
				member:{},
				url: getApp().globalData.url,
				static:getApp().globalData.static,
				version:getApp().globalData.version
			}
		},
		onLoad() {
			var res = uni.getSystemInfoSync();
			this.pic_h   = res.windowWidth*0.76*0.2+"px";
			this.menu_h  = res.windowWidth*0.96*0.24+"px";
			this.radius  = res.windowWidth*0.86*0.2/2+"px";
			this.width  = res.windowWidth;
		},
		onShow(){
			this.member = uni.getStorageSync("member");
		},
		methods: {
			modify:function()
			{
				uni.navigateTo({
					url:"modify_pwd"
				})
			},
			update_version:function()
			{
				var that = this;
				plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
					console.log(widgetInfo);
					uni.request({  
						url: that.url+'/wechat_update_version',  
						data: {  
							version: widgetInfo.version,  
							name: widgetInfo.name  
						},  
						success: (res) => {  
							var data = res.data;  
							console.log(res);
							if(data.update!=0)
							{
								uni.showModal({ //提醒用户更新
									title: "更新提示",  
									content: data.note,  
									success: (res) => {  
										if (res.confirm) 
										{
											if (data.update==1)
											{
												plus.runtime.openURL(data.wgtUrl);  
											}
											if(data.update==2)
											{
												uni.downloadFile({
													url: data.wgtUrl,  
													success: (downloadResult) => {  
														if (downloadResult.statusCode === 200) 
														{  
															plus.runtime.install(downloadResult.tempFilePath, {  
																force: false  
															}, function() {  
																console.log('install success...');  
																plus.runtime.restart();  
															}, function(e) {  
																console.error('install fail...');  
															});  
														}  
													}  
												});
											}
										}  
									}  
								})
							}
							else
							{
								uni.showToast({
									title:"已是最新版本",
									duration:1500,
									icon:"none"
								})
							}
						}  
					});  
				}); 
			},
			outlog:function()
			{
				uni.showModal({
					title:'操作提示',
					content:'确认要退出本账号?',
					success:function(res)
					{
						if(res.confirm)
						{
							uni.removeStorageSync('member_id');
							uni.removeStorageSync('member');
							uni.removeStorageSync('grade');
							uni.showToast({
								title:'操作成功',
								duration:1000
							})
							uni.reLaunch({
								url:'index'
							})
						}
					}
				})
				
			}
		}
	}
</script>


